package model

import (
	"time"

	"gorm.io/gorm"
)

// Attachment 附件模型
type Attachment struct {
	ID          uint           `gorm:"primaryKey" json:"id"`
	Category    string         `gorm:"type:varchar(50);default:'unclassed';comment:类别" json:"category"`
	URL         string         `gorm:"type:varchar(500);not null;comment:物理路径" json:"url"`
	ImageWidth  int            `gorm:"type:int;default:0;comment:宽度" json:"imageWidth"`
	ImageHeight int            `gorm:"type:int;default:0;comment:高度" json:"imageHeight"`
	ImageType   string         `gorm:"type:varchar(50);comment:图片类型/文件扩展名" json:"imageType"`
	ImageFrames int            `gorm:"type:int;default:0;comment:图片帧数" json:"imageFrames"`
	Filename    string         `gorm:"type:varchar(255);not null;comment:文件名" json:"filename"`
	Filesize    int64          `gorm:"type:bigint;default:0;comment:文件大小(字节)" json:"filesize"`
	Mimetype    string         `gorm:"type:varchar(255);comment:Mime类型" json:"mimetype"`
	Extparam    string         `gorm:"type:varchar(500);comment:透传数据" json:"extparam"`
	UploadTime  time.Time      `gorm:"type:datetime;comment:上传时间" json:"uploadTime"`
	Storage     string         `gorm:"type:varchar(50);default:'local';comment:存储引擎" json:"storage"`
	CreatedAt   time.Time      `json:"createdAt"`
	UpdatedAt   time.Time      `json:"updatedAt"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`
}

// TableName 指定表名
func (Attachment) TableName() string {
	return "sys_attachment"
}
